-
Notifications
You must be signed in to change notification settings - Fork 621
chore: Update rate limit to sliding window (10s) #6730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 6d1aebd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6730 +/- ##
=======================================
Coverage 54.76% 54.76%
=======================================
Files 894 894
Lines 56201 56201
Branches 3820 3820
=======================================
Hits 30780 30780
Misses 25326 25326
Partials 95 95
🚀 New features to boost your workflow:
|
size-limit report 📦
|
Merge activity
|
Updates the rate limit to use a sliding window
<!-- start pr-codex -->
---
## PR-Codex overview
This PR focuses on updating the rate limiting functionality in the `rateLimit` function to utilize a sliding window approach instead of a fixed window, enhancing how requests are counted over time.
### Detailed summary
- Renamed `RATE_LIMIT_WINDOW_SECONDS` to `SLIDING_WINDOW_SECONDS`.
- Modified Redis interaction to use `mget` for batch fetching request counts.
- Updated the logic to calculate total requests over the last 10 seconds.
- Removed `sampleRate` handling and its related logic.
- Changed error messages for exceeding rate limits.
- Adjusted tests to align with the new sliding window logic.
> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`
<!-- end pr-codex -->
6d1aebd to
ec099a7
Compare
Updates the rate limit to use a sliding window
PR-Codex overview
This PR focuses on updating the rate limiting mechanism in the
rateLimitfunction to use a sliding window approach instead of a fixed window, enhancing the accuracy of request counting over a 10-second interval.Detailed summary
RATE_LIMIT_WINDOW_SECONDStoSLIDING_WINDOW_SECONDS.rateLimitfunction to calculate total requests over the last 10 seconds.mgetfor batch retrieval of request counts.